package me.landery.modules.sinco.rest;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.landery.modules.sinco.service.CallService;
import me.landery.modules.sinco.service.VipService;
import me.landery.modules.sinco.service.dto.CallQueryCriteria;
import me.landery.modules.sinco.service.dto.VipQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author cc.w
 * @Date 2022/6/7 21:36
 * @Version 1.0
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "Sinco：VIP状态管理")
@RequestMapping("/sinco/vip")
public class VipController {
    private final VipService vipService;
    private static final String ENTITY_NAME = "vip";

    @ApiOperation("查询所有用户的VIP套餐情况")
    @GetMapping
    @PreAuthorize("@el.check('vip:list','admin')")
    public ResponseEntity<Object> queryMode(VipQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(vipService.queryAll(criteria, pageable), HttpStatus.OK);
    }

    @ApiOperation("查询所有用户的VIP套餐情况")
    @GetMapping("/web")
    @PreAuthorize("@el.check('vip:weblist','admin')")
    public ResponseEntity<Object> queryModeWeb(VipQueryCriteria criteria, Pageable pageable){
        vipService.checkUserVip();
        return new ResponseEntity<>(vipService.queryAll(criteria, pageable), HttpStatus.OK);
    }
}
